package day12;

/**
 * @author oldliu
 * @since 1.0
 */
public class Lord {
    public static void main(String[] args) {
        Thread.currentThread().setName("周扒皮");
        Worker w[] = new Worker[]{new Worker("张三"), new Worker("董超"), new Worker("薛霸")};
        for (int i = 0; i < w.length; i++) {
            if (i == 0)
                w[i].setPriority(Thread.MIN_PRIORITY);
            else if (i == 1)
                w[i].setPriority(Thread.NORM_PRIORITY);
            else
                w[i].setPriority(Thread.MAX_PRIORITY);
            w[i].start();
        }
        while (true) {
            try {
                Thread.sleep(1400);
                System.out.println(Thread.currentThread().getName() + "睡醒了，喊长工干活");
                for (Worker worker : w) {
                    worker.interrupt();//中断睡眠
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
